package com.sgb.auction.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.sgb.auction.BR;
import com.sgb.auction.R;
import com.sgb.auction.entity.AuctionListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import java.util.List;

/**
 * Time:2021/11/22
 * AUTHOR:F_Q
 * Description:
 */
public class AuctionHallAdapter  extends BaseRecycleAdapter<AuctionListEntity> {

    public AuctionHallAdapter(Context context, int layout, List<AuctionListEntity> datas) {
        super(context, layout, datas);
    }

    @Override
    public void onBindViewHolder(ItemViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        ImageView hallImg = holder.itemView.findViewById(R.id.hall_img);
        TextView tvPrice = holder.itemView.findViewById(R.id.tv_price);
        TextView hallTime = holder.itemView.findViewById(R.id.hall_time);
        ImageView hallState = holder.itemView.findViewById(R.id.hall_state);
        Glide.with(context)
                .load(datas.get(position).getImage())
                .into(hallImg);
        switch (datas.get(position).getState()){
            case 0://草稿
                break;
            case 1://待拍卖
                hallState.setImageResource(R.mipmap.yj_pm_dpm);
                tvPrice.setText("起拍价：");
                hallTime.setText("开始时间:"+datas.get(position).getAuctionStartTime()+"");
                break;
            case 2://拍卖中
                hallState.setImageResource(R.mipmap.yj_pm_pmz);
                hallTime.setText("结束时间:"+datas.get(position).getAuctionEndTime()+"");
                int version = datas.get(position).getVersion();
                if (version == 0){
                    tvPrice.setText("起拍价：");
                }else {
                    tvPrice.setText("当前价：");
                }
                break;
            case 3://拍卖结束
                tvPrice.setText("成交价：");
                hallState.setImageResource(R.mipmap.yj_pm_pmjs);
                hallTime.setText("结束时间:"+datas.get(position).getAuctionEndTime()+"");
                break;
            case 4://流拍
                break;
        }
    }

    @Override
    public void convert(ItemViewHolder holder, AuctionListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
    }
}
